package com.ep.modules.app.controller;

import com.ep.common.annotation.SysLog;
import com.ep.common.utils.PageUtils;
import com.ep.common.utils.R;
import com.ep.common.validator.ValidatorUtils;
import com.ep.modules.app.entity.AppDataPermission;
import com.ep.modules.app.service.AppDataPermissionService;
import java.util.Map;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/data_permission")
public class AppDataPermissionController {
    @Autowired
    private AppDataPermissionService appDataPermissionService;

    @GetMapping("/list")
    public R list(Map<String, Object> params) {
        PageUtils page = appDataPermissionService.queryPage(params);
        return R.ok().put("page", page);
    }

    @GetMapping("/info/{id}")
    public R info(@PathVariable Long id) {
        AppDataPermission appdatapermission = appDataPermissionService.getById(id);
        return R.ok().put("appdatapermission", appdatapermission);
    }

    @SysLog("保存AppDataPermission")
    @PostMapping("/save")
    public R save(@RequestBody AppDataPermission appdatapermission) {
        ValidatorUtils.validateEntity(appdatapermission);
        appDataPermissionService.save(appdatapermission);
        return R.ok();
    }

    @SysLog("修改AppDataPermission")
    @PostMapping("/update")
    public R update(@RequestBody AppDataPermission appdatapermission) {
        ValidatorUtils.validateEntity(appdatapermission);
        appDataPermissionService.update(appdatapermission);
        return R.ok();
    }

    @SysLog("删除AppDataPermission")
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        appDataPermissionService.deleteBatch(ids);
        return R.ok();
    }
}